﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace ERF.Input
{
    /// <summary>
    /// Represents a button on a keyboard.
    /// </summary>
    public class AssignedKeyboardButton : AssignedButton
    {
        private Keys key;

        public AssignedKeyboardButton(InputHandler handler, Keys key)
            : base(handler)
        {
            this.key = key;
        }

        /// <summary>
        /// Returns a boolean denoting if the button is currently being pressed or not.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonDown()
        {
            return handler.KeyboardState.IsKeyDown((Keys)key);
        }

        /// <summary>
        /// Returns a boolean denoting if the button has just been released.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonReleased()
        {
            return handler.OldKeyboardState.IsKeyDown((Keys)key) && handler.KeyboardState.IsKeyUp((Keys)key);
        }
    }
}
